<?php
class groupController extends accessController{
    public static function _right(){
        return array(
            array('安全设置',1),
            array('管理员组添加','add,add_'),
            array('管理员组列表','li'),
            array('管理员组编辑','mod,mod_'),
        );
    }
    public function index(){
        
    }
    public function add(){
		$group=load_service('group');
		$controllers=$group->list_all_controllers();
		$priv_checkbox=array();
		
        include($this->viewer_dir.'group/add.php');
    }
    public function add_(){
        $group=load_service('group');
        $r=$group->add_($_POST);
        if($r[0]){
            alert('管理员组添加成功！');
            jump('group','add');
        }else{
            alert('管理员组添加失败！'.$r[1]);
            back();
        }
    }
    public function mod(){
        $group=load_service('group');
        $id=intval($_GET['id']);
		$r=$group->is_foundergroupid($id);
        if($r){
            alert('此组不允许编辑或删除！');
            reload();
        }
        $data=$group->mod($id);
		$controllers=$group->list_all_controllers();
        if($data){
			$priv_checkbox=(array) unserialize($data['priv']);
            include($this->viewer_dir.'group/mod.php');
        }
    }
    public function mod_(){
        $group=load_service('group');
        $id=intval($_GET['id']);
		$r=$group->is_foundergroupid($id);
        if($r){
            alert('此组不允许编辑或删除！');
            reload();
        }
        $r=$group->mod_($_POST,$id);
        if($r[0]){
            alert('管理员组编辑成功！');
            reload();
        }else{
            alert('管理员组编辑失败！'.$r[1]);
            back();
        }
    }
	/*
    public function del(){
        $group=load_service('group');
        $id=intval($_GET['id']);
		$r=$group->is_foundergroupid($id);
        if($r){
            alert('此组不允许编辑或删除！');
            reload();
        }
        if($group->del($id)){
            alert('删除成功！');
            jump('group','li');
        }else{
            alert('删除失败！');
            back();
        }
    }
	*/
    public function li(){
        $group=load_service('group');
        $return=$group->li();
        include($this->viewer_dir.'group/list.php');
    }
}